<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./myquery.js"></script>
</head>
<body>
  <button class="btn">发射子弹</button>
  <script>
    // 节流的定义: 单位时间内只执行一次
    $('.btn').onclick = function () {
      throttle()
    }
    var startTime = 0
    function throttle () {
      var endTime = +new Date()
      if (endTime - startTime > 3000) {
        // 可以发射子弹了
        console.log('发射子弹了')
        startTime = endTime
      }
    }
  </script>
</body>
</html>
